1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 import java.awt.font.NumericShaper;
31 import java.util.EnumSet;
32 import static java.awt.font.NumericShaper.*;
33
34 public class EasternArabicTest {
35 static NumericShaper ns_old, ns_new;
36 static boolean err = false;
37
38 static String[][] testData = {
39
40 {"\u0623\u0643\u062a\u0648\u0628\u0631 10",
41 "\u0623\u0643\u062a\u0648\u0628\u0631 \u06f1\u06f0"},
42
43
44 {"\u0b86\u0ba3\u0bcd\u0b9f\u0bc1 2009",
45 "\u0b86\u0ba3\u0bcd\u0b9f\u0bc1 \u0be8\u0be6\u0be6\u0bef"},
46
47
48
49
50 {"\u1200 2009",
51 "\u1200 \u136a00\u1371"},
52
53 };
54
55 public static void main(String[] args) {
56 ns_old = getContextualShaper(TAMIL|ETHIOPIC|EASTERN_ARABIC|ARABIC|THAI|LAO,
57 EUROPEAN);
58 ns_new = getContextualShaper(EnumSet.of(Range.THAI,
59 Range.TAMIL,
60 Range.ETHIOPIC,
61 Range.EASTERN_ARABIC,
62 Range.ARABIC,
63 Range.LAO),
64 Range.EUROPEAN);
65
66
67 StringBuilder cData = new StringBuilder();
68 StringBuilder cExpected = new StringBuilder();
69 for (int i = 0; i < testData.length; i++) {
70 String data = testData[i][0];
71 String expected = testData[i][1];
72 test(data, expected);
73 cData.append(data).append(' ');
74 cExpected.append(expected).append(' ');
75 }
76 test(cData.toString(), cExpected.toString());
77
78 if (err) {
79 throw new RuntimeException("shape() returned unexpected value.");
80 }
81 }
82
83 private static void test(String data, String expected) {
84 char[] text = data.toCharArray();
85 ns_old.shape(text, 0, text.length);
86 String got = new String(text);
87
88 if (!expected.equals(got)) {
89 err = true;
90 System.err.println("Error with traditional range.");
91 System.err.println(" text = " + data);
92 System.err.println(" got = " + got);
93 System.err.println(" expected = " + expected);
94 } else {
95 System.err.println("OK with traditional range.");
96 System.err.println(" text = " + data);
97 System.err.println(" got = " + got);
98 System.err.println(" expected = " + expected);
99 }
100
101 text = data.toCharArray();
102 ns_new.shape(text, 0, text.length);
103 got = new String(text);
104
105 if (!expected.equals(got)) {
106 err = true;
107 System.err.println("Error with new Enum range.");
108 System.err.println(" text = " + data);
109 System.err.println(" got = " + got);
110 System.err.println(" expected = " + expected);
111 } else {
112 System.err.println("OK with new Enum range.");
113 System.err.println(" text = " + data);
114 System.err.println(" got = " + got);
115 System.err.println(" expected = " + expected);
116 }
117 }
118 }